package com.ruoyi.dynamic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dynamic.domain.UserPartyEnroll;
import com.ruoyi.dynamic.service.IUserPartyEnrollService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 约玩报名Controller
 * 
 * @author DEREK
 * @date 2023-12-07
 */
@RestController
@RequestMapping("/dynamic/enroll")
public class UserPartyEnrollController extends BaseController
{
    @Autowired
    private IUserPartyEnrollService userPartyEnrollService;

    /**
     * 查询约玩报名列表
     */
    @PreAuthorize("@ss.hasPermi('dynamic:enroll:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserPartyEnroll userPartyEnroll)
    {
        startPage();
        List<UserPartyEnroll> list = userPartyEnrollService.selectUserPartyEnrollList(userPartyEnroll);
        return getDataTable(list);
    }

    /**
     * 导出约玩报名列表
     */
    @PreAuthorize("@ss.hasPermi('dynamic:enroll:export')")
    @Log(title = "约玩报名", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserPartyEnroll userPartyEnroll)
    {
        List<UserPartyEnroll> list = userPartyEnrollService.selectUserPartyEnrollList(userPartyEnroll);
        ExcelUtil<UserPartyEnroll> util = new ExcelUtil<UserPartyEnroll>(UserPartyEnroll.class);
        util.exportExcel(response, list, "约玩报名数据");
    }

    /**
     * 获取约玩报名详细信息
     */
    @PreAuthorize("@ss.hasPermi('dynamic:enroll:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(userPartyEnrollService.selectUserPartyEnrollById(id));
    }

    /**
     * 新增约玩报名
     */
    @PreAuthorize("@ss.hasPermi('dynamic:enroll:add')")
    @Log(title = "约玩报名", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserPartyEnroll userPartyEnroll)
    {
        return toAjax(userPartyEnrollService.insertUserPartyEnroll(userPartyEnroll));
    }

    /**
     * 修改约玩报名
     */
    @PreAuthorize("@ss.hasPermi('dynamic:enroll:edit')")
    @Log(title = "约玩报名", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserPartyEnroll userPartyEnroll)
    {
        return toAjax(userPartyEnrollService.updateUserPartyEnroll(userPartyEnroll));
    }

    /**
     * 删除约玩报名
     */
    @PreAuthorize("@ss.hasPermi('dynamic:enroll:remove')")
    @Log(title = "约玩报名", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userPartyEnrollService.deleteUserPartyEnrollByIds(ids));
    }
}
